(function(){
	var liEl, liElSub,
		spanEl = $("#sidebar span");

	switch($.trim($(".page-title").html())){
		case "控制台":
			spanEl.each(function(i){
				if (spanEl[i].innerHTML == "控制台"){
					liEl = spanEl[i].closest('li');
					$(liEl).addClass("active");
				}
			});
			break;
		case "分类列表":
			spanEl.each(function(i){	
				if (spanEl[i].innerHTML == "产品管理"){
					liEl = spanEl[i].closest('li');
					$(liEl).addClass("active");
					liElSub = $(liEl).find("li");
					liElSub.each(function(j){
						if (($(liElSub[j]).children("a"))[0].innerHTML ==  "分类列表"){
							$(liElSub[j]).addClass("active");
						}
					});
				}
			});
			break;
		case "产品列表":
			spanEl.each(function(i){	
				if (spanEl[i].innerHTML == "产品管理"){
					liEl = spanEl[i].closest('li');
					$(liEl).addClass("active");
					liElSub = $(liEl).find("li");
					liElSub.each(function(j){
						if (($(liElSub[j]).children("a"))[0].innerHTML ==  "产品列表"){
							$(liElSub[j]).addClass("active");
						}
					});
				}
			});
			break;
		case "工程案例":
			spanEl.each(function(i){
				if (spanEl[i].innerHTML == "工程案例"){
					liEl = spanEl[i].closest('li');
					$(liEl).addClass("active");
				}
			});
			break;
		case "关于我们":
			spanEl.each(function(i){
				if (spanEl[i].innerHTML == "关于我们"){
					liEl = spanEl[i].closest('li');
					$(liEl).addClass("active");
				}
			});
			break;
		default:
			alert("导航栏无法设置当前焦点");
	}
})();

